<?php 
	session_start();
	if(!isset($_SESSION['username']))
		header("location:../index.php");
	$main_id ="";
	$sub_id = "";
	$dirname = "";
	$_SESSION["file_info"] = array();
	if(isset($_SESSION['folder']))  $dirname = "../../images/uploads/".$_SESSION['folder']."/";
	if(isset($_SESSION['main_id'])) $main_id = $_SESSION['main_id'];
	if(isset($_SESSION['sub_id'])) 	
	{
		$sub_id = $_SESSION['sub_id'];
		if($sub_id == "")			$sub_id = 0;			
	} 
	

?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SWFUpload Demos - Resize Demo</title>
<link href="../css/upload.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../admin_css/product.css" type="text/css" />
<script type="text/javascript" src="../swfupload/swfupload.js"></script>
<script type="text/javascript" src="../js/handlers.js"></script>
<script type="text/javascript" src="../js/page_function/products.js"></script>
<script type="text/javascript">

var swfu;
window.onload = function () {
	swfu = new SWFUpload({
		// Backend Settings
		upload_url: "../command/image/images_upload.php",
		post_params: {"PHPSESSID": "<?php echo session_id(); ?>"},

		// File Upload Settings
		file_size_limit : "10 MB",
		file_types : "*.jpg;*.png",
		file_types_description : "JPG Images; PNG Image",
		file_upload_limit : 0,

		// Event Handler Settings - these functions as defined in Handlers.js
		//  The handlers are not part of SWFUpload but are part of my website and control how
		//  my website reacts to the SWFUpload events.
		swfupload_preload_handler : preLoad,
		swfupload_load_failed_handler : loadFailed,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,

		// Button Settings
		button_image_url : "images/SmallSpyGlassWithTransperancy_17x18.png",
		button_placeholder_id : "spanButtonPlaceholder",
		button_width: 180,
		button_height: 18,
		button_text : '<span class="button">Select Images <span class="buttonSmall">(2 MB Max)</span></span>',
		button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
		button_text_top_padding: 0,
		button_text_left_padding: 18,
		button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
		button_cursor: SWFUpload.CURSOR.HAND,
		
		// Flash Settings
		flash_url : "../swfupload/swfupload.swf",
		flash9_url : "../swfupload/swfupload_fp9.swf",

		custom_settings : {
			upload_target : "divFileProgressContainer",
			thumbnail_height: 600,
			thumbnail_width: 600,
			thumbnail_quality: 100
		},
		
		// Debug Settings
		debug: false
	});
};
	
	</script>
</head>
<body>

<div id="content">
	<h3>เพิ่มรูปภาพสินค้า</h3>
	
	<?php 
	if($_SESSION['edit'])
	{
		include("../command/image/searchImages.php");
	}
	?>
	<form>
		<table>
			<tr>
				<td>
					<div style="width: 180px; height: 18px; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
						<span id="spanButtonPlaceholder"></span>					
					</div>	
				</td>
				<td>
					<a href="#" onClick="dia_imagesAdd_progress()" style="text-decoration:none; font-size:12px;"> <img src="../images/symbol/arrow_refresh.png"/> &nbsp; คลิกเพื่อแสดงรูปภาพ</a>
				</td>
			</tr>			
		</table>
		<br>
		<input id='btnSave' value='บันทึก' type='button' style='width:70px;' onclick='dia_images_complete(<?=$main_id.",".$sub_id?>);'>
	</form>

	<div id="divFileProgressContainer" style="height: 75px;" ></div>
	<div id="thumbnails">
		
	</div>
</div>
</body>
</html>
